package com.css.zfzx.fwsjcj.modules.app.service.Impl;

import com.css.bpm.platform.utils.UUIDGenerator;
import com.css.zfzx.fwsjcj.commen.util.Constant;
import com.css.zfzx.fwsjcj.modules.app.entity.FwAppVersionEntity;
import com.css.zfzx.fwsjcj.modules.app.entity.FwVersionEntity;
import com.css.zfzx.fwsjcj.modules.app.repository.AppRepository;
import com.css.zfzx.fwsjcj.modules.app.repository.FwAppRepository;
import com.css.zfzx.fwsjcj.modules.app.service.AppManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
@Service
public class AppManageServiceImpl implements AppManageService {
    @Autowired
    AppRepository appRepository;
    @Autowired
    FwAppRepository fwAppRepository;
    @Override
    public void saveApp(FwAppVersionEntity fwAppVersionEntity) {
        fwAppVersionEntity.setAppId(UUIDGenerator.getUUID());
        fwAppVersionEntity.setCreateTime(new Date());
        fwAppVersionEntity.setDelFlag(Constant.IS_VALID_YES);
        appRepository.save(fwAppVersionEntity);
    }

    @Override
    public FwAppVersionEntity findByType(String type) {
        FwAppVersionEntity appVersionEntity = appRepository.findByType(type);
        return appVersionEntity;
    }

    @Override
    public FwVersionEntity getAppVersion(String platform) {
        FwVersionEntity fwVersion =fwAppRepository.getAppVersion(platform);
        return fwVersion;
    }
}
